package com.wordLearning.word.infra.basic.service.impl;

import com.wordLearning.word.infra.basic.entity.Word;
import com.wordLearning.word.infra.basic.dao.WordDao;
import com.wordLearning.word.infra.basic.service.WordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Word)表服务实现类
 *
 * @author makejava
 * @since 2025-03-10 13:28:07
 */
@Service("wordService")
public class WordServiceImpl implements WordService {
    @Resource
    private WordDao wordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param wordId 主键
     * @return 实例对象
     */
    @Override
    public Word queryById(Integer wordId) {
        return this.wordDao.queryById(wordId);
    }

    /**
     * 分页查询
     *
     * @param word 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */

    /**
     * 新增数据
     *
     * @param word 实例对象
     * @return 实例对象
     */
    @Override
    public Word insert(Word word) {
        this.wordDao.insert(word);
        return word;
    }

    /**
     * 修改数据
     *
     * @param word 实例对象
     * @return 实例对象
     */
    @Override
    public int update(Word word) {
        return this.wordDao.update(word);
    }

    /**
     * 通过主键删除数据
     *
     * @param wordId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer wordId) {
        return this.wordDao.deleteById(wordId) > 0;
    }

    @Override
    public int countByCondition(Word word) {
        return this.wordDao.countByCondition(word);
    }

    @Override
    public List<Word> queryPage(Word word, int start, Integer pageSize) {
        return this.wordDao.queryPage(word,start,pageSize);
    }

    @Override
    public Word queryWordBySpelling(String spelling) {
        return this.wordDao.queryBySpelling(spelling);
    }

    @Override
    public List<Word> setLearningPlan(Word word, int start, Integer pageSize, List<Integer> learnedList) {
        return this.wordDao.setLearningPlan(word,start,pageSize,learnedList);
    }

    @Override
    public Word queryWordById(Integer wordId) {
        return this.wordDao.queryById(wordId);
    }
}
